package com.theaf.core.shiro;

import org.apache.shiro.cache.AbstractCacheManager;
import org.apache.shiro.cache.Cache;
import org.apache.shiro.cache.CacheException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

@Component
public class ShrioRedisCacheManager extends AbstractCacheManager {

	@Autowired
	private RedisTemplate redisTemplate;

	public ShrioRedisCacheManager(RedisTemplate redisTemplate){
		this.redisTemplate = redisTemplate;
	}

	@Override
	protected Cache<String, Object> createCache(String name) throws CacheException {
		return new ShrioRedisCache<String, Object>(redisTemplate, name);
	}
}
